/**
 *  This file is part of OhSnap.
 *
 * 	Copyright (c) 2009 Gabriel Mendon�a and Marcelo Machado
 * 
 *  OhSnap is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  OhSnap is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with OhSnap.  If not, see <http://www.gnu.org/licenses/>.
 *  
 */
package br.mm.cg.particles;

import processing.core.PApplet;
import processing.core.PGraphics;
import processing.core.PVector;

/**
 * @author machado
 * 
 */
public class Particle {

	private static final float SIZE = 15.0f;
	protected PApplet parent;
	protected PVector position;
	protected PVector velocity;
	protected float distance;
	protected float speed;
	protected float[] color;

	/**
	 * Constructor.
	 * 
	 * @param pApplet
	 *            the PApplet where this Particle will be drawn.
	 * @param position
	 *            a PVector with the position of the particle
	 * @param color
	 *            an int array representing the particle's color in RBG.
	 */
	public Particle(PApplet pApplet, PVector position, PVector movement,
			float[] color) {
		parent = pApplet;

		this.position = position;
		this.velocity = movement;
		this.color = color;
		this.distance = 0.0f;
		this.speed = 1.5f;
	}

	/**
	 * Draws the particle.
	 * @param pGraphics 
	 */
	public void draw(PGraphics pGraphics) {
		pGraphics.pushMatrix();
		pGraphics.translate(position.x, position.y, position.z);

		if (color.length == 3) {
			pGraphics.fill(color[0], color[1], color[2]);
		} else if (color.length == 4) {
			pGraphics.fill(color[0], color[1], color[2], color[3]);
		}

		drawGeometry(pGraphics);
		pGraphics.popMatrix();
	}

	/**
	 * Draws the geometric object.
	 * @param pGraphics 
	 */
	private void drawGeometry(PGraphics pGraphics) {
		pGraphics.box(SIZE);
	}

}